<?php
	require_once('lib/start.php');

	$url = get_input('query');
	$social_data = socialgraph_query($url);

	$service = stalk_guess_service($url);
?>
<html>
	<head>
		<title>Stalk-O-Matic(beta): Report for <?php echo $url; ?></title>
		<link rel="stylesheet" href="style.css" type="text/css" />
		<?php echo get_header($service); ?>
	</head>
	<body>
		<div id="page">
		
			<table width="100%">
				<tr>
					<td valign="top">
					
						<div id="details">
						
							<div id="usericon"><img src="<?php echo get_user_icon($service, $url); ?>" /></div>

							<?php
								$location = get_location($service, $url);

								if ($location)
								{
									?>
										<div id="location"><p>Location according to <?php echo $service; ?>: <a href="http://www.neighborhoodlens.com/search.php?q=<?php echo urlencode($location); ?>"><?php echo $location ?></a></p></div>
									<?php
								}
							?>
							
							<?php 
								$tags = get_tags($service, $url);
								if ($tags) {
							?>
								<div id="tags">
									<p>Interests</p>
									<p>
									<?php
										foreach ($tags as $tag) {
											echo "$tag ";
										} 
									 ?>
									 </p>
								</div>
							<?php
								}
							?>
						</div>
						
						<div id="other_sites">
							<?php
								if (($social_data) && (isset($social_data->nodes)))
								{
									?>
									<h1>Also known as</h1>
									<?php
									foreach ((array)$social_data->nodes as $u=>$data) {

										$s = stalk_guess_service($u);
										$i = get_service_icon_url($s);
										?>
											<div id="node"><img src="<?php echo $i; ?>" /><a href="<?php echo $CONFIG->url; ?>report.php?query=<?php echo urlencode($u); ?>"><?php echo "$s ($u)"; ?></a></div>
										<?php
									}
								}
							?>
						</div>
						
						<div id="friends">
							<?php 
								$friends = get_friends($service, $url);

								if ($friends)
								{
							?>
									<h1>Friends on this service</h1>
									<?php 

										foreach ($friends as $f)
										{

											$f_url = $f->url;
											$f_service = stalk_guess_service($f_url);
											$f_icon = get_service_icon_url($f_service);
											$f_name = $f->name;
									?>								
												<img src="<?php echo $f_icon; ?>" /><a href="report.php?query=<?php echo urlencode($f_url); ?>"><?php echo $f_name; ?></a>
										
									<?php
										}
									?>
							<?php	
								}
							?>
						</div>
						
						
					</td>
				
					<td valign="top" width="70%">
						<div id="latest_content">
							<?php 
								$content = get_rendered_contents($url, $service);
								
								if ($content)
								{
								?>
									<div id="latest_content_header"><h1>Latest content on <?php echo $service; ?></h1></div>
									<?php echo $content; ?>
								<?php 
								}
							?>
						</div>

					</td>
				</tr>
			</table>

		</div>
	</body>
</html>
